<?

function page_menu($current_user)
{
   if(!isset($current_user['rights'])) return '';
   
   $can_addnewbug = check_user_right('bugs', 'add_bug',   $current_user['rights']);
   $can_viewbugs  = check_user_right('bugs', 'view_bugs', $current_user['rights']);
   
   $can_view_places = check_user_right('sections', 'view_places', $current_user['rights']);
   $can_view_types  = check_user_right('sections', 'view_types',  $current_user['rights']);
   $can_view_ctypes = check_user_right('sections', 'view_ctypes', $current_user['rights']);
   $can_view_levels = check_user_right('sections', 'view_levels', $current_user['rights']);
   
   $can_view_reference = ($can_view_places || $can_view_types);
   
   $can_view_users = check_user_right('sections', 'view_users', $current_user['rights']);


   $addnewbug = "<div class='dvMenuCell'   ><a href='"._basedomain."/newbug' class='wh' >"._menu_newbug."</a></div><div class='dvMenuCellSp' >&nbsp;</div>";
   $bugs      = "<div class='dvMenuCell'   ><a href='"._basedomain."/bugs' class='wh' >"._menu_bugs."</a></div><div class='dvMenuCellSp' >&nbsp;</div>";
   $bugs     .= "<div class='dvMenuCell'   ><a href='"._basedomain."/favs' class='wh' >"._menu_favs."</a></div><div class='dvMenuCellSp' >&nbsp;</div>";
   $reference = "<div class='dvMenuCell wh' id='dvSubMenuOpener' onmouseover='showsubmenu(\"#dvSubMenu\", \"#\"+this.id);' onmouseout='hidesubmenu(\"#dvSubMenu\", \"#\"+this.id);' >"._menu_refc."</div><div class='dvMenuCellSp' >&nbsp;</div>";
   $users     = "<div class='dvMenuCell'   ><a href='"._basedomain."/users' class='wh' >"._menu_users."</a></div><div class='dvMenuCellSp' >&nbsp;</div>";

   $ref_places = "<div class='dvSubMenuCell' ><a href='"._basedomain."/ref/places' class='wh' >"._menu_refplaces."</a></div><div class='dvMenuCellWh'  >&nbsp;</div>";
   $ref_types  = "<div class='dvSubMenuCell' ><a href='"._basedomain."/ref/types'  class='wh' >"._menu_reftypes."</a></div><div class='dvMenuCellWh'  >&nbsp;</div>";
   $ref_ctypes = "<div class='dvSubMenuCell' ><a href='"._basedomain."/ref/ctypes' class='wh' >"._menu_refctypes."</a></div><div class='dvMenuCellWh'  >&nbsp;</div>";
   $ref_levels = "<div class='dvSubMenuCell' ><a href='"._basedomain."/ref/levels' class='wh' >"._menu_reflevels."</a></div><div class='dvMenuCellWh'  >&nbsp;</div>";

   $menu  = ($can_addnewbug) ? $addnewbug : '';
   $menu .= ($can_viewbugs)  ? $bugs : '';
   
   $menu .= ($can_view_reference) ? $reference : '';
   $menu .= ($can_view_users) ? $users : '';
   
   $submenu  = ($can_view_places) ? $ref_places : '';
   $submenu .= ($can_view_types ) ? $ref_types  : '';
   $submenu .= ($can_view_ctypes) ? $ref_ctypes : '';
   $submenu .= ($can_view_levels) ? $ref_levels : '';
   
   return "
<div id='dvMenuHolder'>
   <div id='dvMenu' >
      <div class='dvMenuCellSp' >&nbsp;</div>
      ".$menu."
      <div class='dvMenuCellSp' >&nbsp;</div>
   </div>
</div>

<div id='dvSubMenu' onmouseover='showsubmenu(\"#\"+this.id, \"#dvSubMenuOpener\");' onmouseout='hidesubmenu(\"#\"+this.id, \"#dvSubMenuOpener\");' >
   <div class='dvMenuCellWh'  >&nbsp;</div>
   ".$submenu."
</div>
";

}



?>
